package com.sunyard.log;

import ch.qos.logback.core.PropertyDefinerBase;
import lombok.extern.slf4j.Slf4j;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

@Slf4j
public class MachineInfo extends PropertyDefinerBase {
    @Override
    public String getPropertyValue() {
        Process hostname = null;
        try {
            hostname = Runtime.getRuntime().exec("hostname");
            BufferedReader stdInput = new BufferedReader(new InputStreamReader(hostname.getInputStream()));
            String s;
            if ((s = stdInput.readLine()) != null) {
                return s;
            }
        } catch (IOException e) {
            log.error("系统未捕获异常信息:", e);
        }
        return null;
    }
}